package com.headfirst.StructuralMode.adapter;

/**
 * 适配器实现了目标接口，并持有被适配者的实例
 */
public class TurkeyAdapter implements Duck {

    // 被适配者接口
    private Turkey turkey;

    public TurkeyAdapter(Turkey turkey) {
        this.turkey = turkey;
    }

    @Override
    public void quack() {
        turkey.gobble();
    }

    @Override
    public void fly() {
        for (int i = 0; i < 5; i++) {
            turkey.fly();
        }
    }
}
